# coding: utf-8

from elasticsearch import Elasticsearch

es = Elasticsearch(hosts="172.16.212.233:9200")
body = {
    'query': {
        'term': {
            'age': 1234
        }
    }
}
# https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-request-query.html
res = es.search(index='wangsir', doc_type='user', body=body)
print(res['hits']['total'])
arr = res['hits']['hits']
for item in arr:
    print(item['_source'])